import java.util.HashSet;

/**
 * @Description:强密码检验器 II
 * @Date:Create in 21:19  2022/6/13
 */
public class strongPasswordCheckerII2299 {

    public static void main(String[] args) {
        String password = "Me+You--IsMyDream";
        System.out.println(strongPasswordCheckerII(password));
    }

    public static boolean strongPasswordCheckerII(String password) {
        int size = password.length();
        if (size < 8) {
            // 至少8个字符
            return false;
        }

        //特殊字符
        HashSet<Character> set = new HashSet<>();
        for (char c : "!@#$%^&*()-+".toCharArray()) {
            set.add(c);
        }
        //至少一个小写字母
        boolean atLeastLowLettr = false;
        //至少一个大写字母
        boolean atLeastSupperLetter = false;
        //至少一个数字
        boolean atLeastIsdigit = false;
        //至少 一个特殊字符
        boolean atLeastSpecStr = false;

        for (int i = 0; i < size; i++) {
            char c = password.charAt(i);
            if (i > 0 && c == password.charAt(i - 1)) {
                return false;
            }
            if (c >= 'a' && c <= 'z') {
                atLeastLowLettr = true;
            } else if (c >= 'A' && c <= 'Z') {
                atLeastSupperLetter = true;
            } else if (Character.isDigit(c)) {
                atLeastIsdigit = true;
            } else if (set.contains(c)) {
                atLeastSpecStr = true;
            }

        }
        return atLeastLowLettr && atLeastSupperLetter && atLeastIsdigit && atLeastSpecStr;
    }
}
